<?php
/*
 * This scaffolding is designed by Xrvel
 * http://www.xrvel.com/
 */

define('XS_DATA_EMPTY', 'Fill all input');
define('XS_DATA_ADD_OK', 'Data has been added');
define('XS_DATA_ADD_ERROR', 'Data can not be added');
define('XS_DATA_DELETE_OK', 'Data has been deleted');
define('XS_DATA_DELETE_ERROR', 'Data can not be deleted');
define('XS_DATA_EDIT_OK', 'Data has been edited');
define('XS_DATA_EDIT_ERROR', 'Data can not be edited');

// Print query to screen ?
$config['xrvel_scaffolding_print_query'] = false;

$config['xrvel_scaffolding'] = array();

// Config for each table

////////////////////////////////////////////////
$config['xrvel_scaffolding']['foods'] = array(
	'friendly_name' => 'Foods',
	'columns' => array(
		array(
			'name' => 'food_id',
			'type' => 'int',
			'ci_rule' => 'trim|required',
			'primary_key' => true,/* Mark as primary key */
			'friendly_name' => 'ID'/* Optional : friendly column name */
		),
		array(
			'name' => 'food_name',
			'type' => 'varchar',
			'ci_rule' => 'trim|min_length[5]|max_length[255]|required',
			'friendly_name' => 'Name of the food',
			'add_note' => 'You can fill food name here',/* Optional : instruction on add form */
			'edit_note' => 'You can fill food name here'/* Optional : instruction on edit form */
		),
		array(
			'name' => 'food_price',
			'type' => 'int',
			'ci_rule' => 'trim|integer|max_length[8]|required',
			'friendly_name' => 'The Price',
			'on_view' => 'my_number_format'/* Optional : number_formatting function */
		),
		array(
			'name' => 'food_type_id',
			'type' => 'int',
			'ci_rule' => 'trim|integer|required',
			'load_from' => array(
				'table' => 'food_types',
				'join_type' => 'JOIN',
				/* 'column' => 'food_type_id', OPTIONAL , if column name is different */
				'display' => 'food_type_name',
				'where' => array()/* Optional : used when you want to add where when loading the data */
			),
			'skip_parent' => true
		),
		array(
			'name' => 'food_taste_id',
			'type' => 'int',
			'ci_rule' => 'trim|integer|required',
			'load_from' => array(
				'table' => 'food_tastes',
				'join_type' => 'JOIN',
				/* 'column' => 'food_taste_id', OPTIONAL , if column name is different */
				'display' => 'food_taste_name',
				'friendly_name' => 'How It Tastes',
				'where' => array()/* Optional : used when you want to add where when loading the data */
			),
			'skip_parent' => true
		),
		array(
			'name' => 'food_tastes.food_taste_comment',
			'additional_join' => true,
			'friendly_name' => 'Comment about food taste'
		),
		array(
			'name' => 'food_tastes.food_taste_source_example',
			'additional_join' => true
		),
		array(
			'name' => 'food_comment',
			'type' => 'text',
			'ci_rule' => 'trim',
			'friendly_name' => 'Comment ?'
		),
		array(
			'name' => 'food_not_viewable',
			'type' => 'int',
			'ci_rule' => 'trim|integer|required',
			'friendly_name' => 'Junk column',
			'hide_on' => array(/* Optional : hide on ? */
				'edit',
				'view'
			)
		),
		array(
			'name' => 'insert_time',
			'type' => 'int',
			'ci_rule' => 'trim|integer|required',
			'editable' => false,/* Optional : editable on edit ? */
			'hide_on' => array(/* Optional : hide on ? */
				'edit',
				'view'
			),
			'on_view' => 'my_custom_date'/* Optional : call user function to format the output */
		)
	),
	'order_by' => array(
		'food_name ASC',
		'food_id ASC'
	)
);

////////////////////////////////////////////////
$config['xrvel_scaffolding']['food_tastes'] = array(
	'friendly_name' => 'Food Tastes',
	'columns' => array(
		array(
			'name' => 'food_taste_id',
			'type' => 'int',
			'ci_rule' => 'trim|required',
			'primary_key' => true
		),
		array(
			'name' => 'food_taste_name',
			'type' => 'varchar',
			'ci_rule' => 'trim|min_length[5]|max_length[100]|required'
		),
		array(
			'name' => 'food_taste_comment',
			'type' => 'varchar',
			'ci_rule' => 'trim'
		),
		array(
			'name' => 'food_taste_source_example',
			'type' => 'varchar',
			'ci_rule' => 'trim|min_length[5]|max_length[100]|required',
		),
	),
	'order_by' => array(
		'food_taste_id ASC',
		'food_taste_name ASC'
	)
);

////////////////////////////////////////////////
$config['xrvel_scaffolding']['food_types'] = array(
	'friendly_name' => 'Food Types',
	'columns' => array(
		array(
			'name' => 'food_type_id',
			'type' => 'int',
			'ci_rule' => 'trim|required',
			'primary_key' => true
		),
		array(
			'name' => 'food_type_name',
			'type' => 'varchar',
			'ci_rule' => 'trim|min_length[5]|max_length[100]|required'
		),
		array(
			'name' => 'last_edit',
			'type' => 'int',
			'ci_rule' => 'trim|required',
			'hide_on' => array(
				'edit'
			),
			'dont_treat_as_int' => true,
			'on_add' => 'my_time',/* Optional : function to be called to fill on add */
			'on_edit' => 'my_time',/* Optional : function to be called to fill on edit */
			'on_view' => 'my_custom_date'
		),
		array(
			'name' => 'insert_time',
			'type' => 'int',
			'ci_rule' => 'trim|required',
			'hide_on' => array(
				'edit'
			),
			'dont_treat_as_int' => true,
			'on_add' => 'my_time',/* Optional : function to be called to fill on add */
			'on_view' => 'my_custom_date'
		)
	),
	'order_by' => array(
		'food_type_id ASC',
		'food_type_name ASC'
	)
);
?>